<?php

  function debug($str) {
    if (defined('SITE_DEBUGGING')) {
      if (!isset($_SESSION['debug'])) {
        $_SESSION['debug'] = null;
      }
      $_SESSION['debug'][count($_SESSION['debug'])] = time() ." : {$str}";
    }
  }
  
  function siteError($errorNumber, $errorString, $errorFile) {
    debug($errorString . " in " . $errorFile);
  }

  function outputDebug() {
    echo '<hr>';
    if (count($_SESSION['debug']) > 0) {
      arsort($_SESSION['debug']);
      foreach ($_SESSION['debug'] as $debugItem) {
        echo $debugItem . "<br />";
      }
    }
    $_SESSION['debug'] = null;
    echo "<pre>";
    var_dump($_SESSION);
    echo "</pre>";
  }
  
  function displayLinks() {
    ?>
    <li class="links"><a href="index.php" title="You're already here">Login</a></li>
    <li class="links"><a href="index.php?area=rules" title="Boardwinia Rules">Rules</a></li>
    <li class="links"><a href="index.php?area=gallery" title="Boardwinia Gallery!">Gallery</a></li>
    <li class="links"><a href="http://www.introversion.co.uk/multiwinia/" title="Website of Multiwinia" rel="external">Multiwinia</a></li>
    <li class="links"><a href="http://www.introversion.co.uk/" title="The website of Introversion" rel="external">Introversion</a></li>
    <li class="links"><a href="http://forums.introversion.co.uk/introversion/" title="Introversion Forums" rel="external">Forums</a></li>
    <?php
  }
    
  function isValidUsername($usr) {
    if ($usr != "") {
      return true;
    } else {
      return false;
    }
  }

  function cleanText($str) {
    $str = trim($str);
    $str = strip_tags($str);
    $str = htmlspecialchars($str);
    return $str;
  }

?>
